// services/api.js
const { get, post } = require('../utils/request.js');

// 测试接口
const testAPI = {
  hello: () => get('/test/hello'),
  echo: (data) => post('/test/echo', data),
  getUser: (id) => get(`/test/user/${id}`)
};

const homeAPI = {
  // http://localhost:8080/api/home/homepage
  fetchHomePage:(requestParams)=>get('/home/homepage', requestParams)
}

const goodsAPI = {
  fetchGoodsList:(requestParams)=>get('products/goods', requestParams)
}

// 用户相关接口
const userAPI = {
  login: (data) => post('/users/login', data),
  getProfile: () => get('/users/profile'),
  updateProfile: (data) => put('/users/profile', data)
};

// 商品相关接口
const productAPI = {
  getList: (params) => get('/products', params),
  getDetail: (id) => get(`/products/${id}`),
  search: (keyword) => get(`/products/search?keyword=${keyword}`)
};

module.exports = {
  testAPI,
  userAPI,
  homeAPI,
  productAPI
};